import { Logger } from "@/utils/Logger";

export class GameConfig {

    public static Config_Name: string = "game"

    public static GameId = {
        Legend: 1, //平民传奇
        Dark: 2, //暗黑
    }


    public gameid:number;
    public gamename:string;

    public static configMap: Map<number, GameConfig> = new Map<number, GameConfig>();

    private static obj2Config(obj: object) {
        let config: GameConfig = new GameConfig();
        for (let key in obj) {
            if (typeof (obj[key]) !== "function")
                config[key] = obj[key];
        }
        return config;
    }
    
    public static json2Config(jsonObj: Object) {
        Object.keys(jsonObj).forEach((key) => {
            let config: GameConfig = this.obj2Config(jsonObj[key]);
            this.configMap.set(config.gameid, config);
        });
        Logger.log("GameConfig.config=", this.configMap)
    }


}